using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
using System.IO;
namespace ProcessesSMS
{
	/// <summary>
	/// Summary description for VIETWEB.
	/// </summary>
	public class VIETWEB
	{
		#region Declare		
		private SMS_MO WMO;
		private SMS_MT WMT;		
		ArrayList arr = new ArrayList();
		public VIETWEB(SMS_MO MO)
		{
			WMO = MO;
		}

		public VIETWEB()
		{
		}
		#endregion
		#region Method
		public void run()
		{
			WMT = new SMS_MT(WMO);
			string tmpMsg = WMO.Message.Substring(WMO.CommandCode.Length).Trim().Replace("  ", " ").Replace("  ", " ");
			tmpMsg = tmpMsg.Replace("  ", " ").Trim();
			//string[] msg = tmpMsg.Split(new char[] { ' ' });			
			//if(msg.Length ==1)
			//{
				//kiem tra dau so				
				string strcurrency="500";
				if(WMO.ServiceID.Replace("04","")=="6072")
					strcurrency="500";
				else if(WMO.ServiceID.Replace("04","")=="6172")
					strcurrency="1000";
				else if(WMO.ServiceID.Replace("04","")=="6272")
					strcurrency="2000";
				else if(WMO.ServiceID.Replace("04","")=="6372")
					strcurrency="3000";
				else if(WMO.ServiceID.Replace("04","")=="6472")
					strcurrency="4000";
				else if(WMO.ServiceID.Replace("04","")=="6572")
					strcurrency="5000";
				else if(WMO.ServiceID.Replace("04","")=="6672")
					strcurrency="10000";
				else if(WMO.ServiceID.Replace("04","")=="6772")
					strcurrency="15000";

				TextWriter twriter = new StreamWriter("VWdir\\" + WMO.CommandCode.ToUpper() + "_" + WMO.MO_ID + ".txt");
				twriter.Write(tmpMsg + "," + WMO.UserID + "," + WMO.RequestTime + "," + strcurrency);
			    twriter.Close();
				WMT.AddMessage(WMO.UserID, "Ban da nap " + strcurrency + " dong cho tai khoan " + tmpMsg + ".Cam on ban da su dung dich vu cua chung toi", SMS_ContentType.SMS_TEXT);				
			//}
			//else
			//{
			//	WMT.AddMessage(WMO.UserID, "Soan tin TV,TC USERNAME gui 6x72 de nap tien vao tai khoan", SMS_ContentType.SMS_TEXT);
			//}
			WMT.MsgType = SMS_MsgType.SMS_TINHTIEN;
			WMT.Insert();
			return;
		}	

		#endregion
	}
}
